package bocchi.card;

import bocchi.BocchiCore;
import bocchi.base.BaseCustomCard;
import bocchi.base.BaseCustomPower;
import bocchi.general.Util;
import bocchi.power.AnxietyPower;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;

public class ScarySociety extends BaseCustomCard {
    private static final String RAW_ID = ScarySociety.class.getSimpleName();
    public static final String GAME_ID = BocchiCore.getGameID(RAW_ID);

    public ScarySociety() {
        super(RAW_ID);
    }

    @Override
    public void use(AbstractPlayer player, AbstractMonster monster) {
        AbstractPower power = new BaseCustomPower(RAW_ID, AbstractPower.PowerType.BUFF, player, magicNumber) {
            @Override
            public void updateDescription() {
                AbstractPower anxiety = player.getPower(AnxietyPower.GAME_ID);
                int totalBlock = amount * (anxiety != null ? anxiety.amount * magicNumber : 0);
                description = String.format(descriptions[0], totalBlock);
            }

            @Override
            public void atEndOfTurn(boolean isPlayer) {
                if (isPlayer) {
                    flash();
                    AbstractPower anxiety = player.getPower(AnxietyPower.GAME_ID);
                    int totalBlock = amount * (anxiety != null ? anxiety.amount * magicNumber : 0);
                    if (totalBlock > 0) {
                        addToBot(new GainBlockAction(player, player, totalBlock));
                    }
                }
            }
        };

        Util.applyPower(player, player, power);
    }
}
